//
//  WithdrawPopBankListViewCell.swift
//  d11
//
//  Created by peale on 2018/11/15.
//  Copyright © 2018年 Tech_001. All rights reserved.
//

import UIKit

class WithdrawPopBankListViewCell: UITableViewCell {
    var bgImgView : UIImageView?
    var iconImgView : UIImageView?
    var nameLabel:UILabel?
    var typeBtn:UIButton?
    var noLabel:UILabel?
    var arrowImgView : UIImageView?
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.setUpUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    func setUpUI() -> Void {
        //e95a74卡的类型
        self.backgroundColor  = UIColor.white
        self.selectionStyle = UITableViewCell.SelectionStyle.none
        self.bgImgView = UIImageView.init()
        self.bgImgView?.image = imageNamed("icon_bank_list_bg_default")
         self.bgImgView?.isUserInteractionEnabled = true
        self.contentView.addSubview(bgImgView!);
        self.bgImgView?.snp.makeConstraints{(make) in
            make.width.equalToSuperview()
            make.height.equalTo(82)
            make.centerX.equalTo(self.contentView)
        };
        
//        self.iconImgView = UIImageView.init()
//        self.iconImgView?.image = imageNamed("icon_depoist_type_list_head_icon")
//        self.bgImgView?.addSubview(self.iconImgView!)
//        self.iconImgView?.snp.makeConstraints{(make) in
//            make.width.equalTo(19)
//            make.height.equalTo(19)
//            make.left.equalToSuperview().offset(17)
//            make.top.equalToSuperview().offset(17)
//        }
        
        self.nameLabel = UILabel.init()
    //    self.nameLabel?.text = "中国工商银行"
        self.nameLabel?.textColor = UIColor.white
        self.nameLabel?.textAlignment = .left
        self.nameLabel?.font = UIFont.systemFont(ofSize: 14)
        self.bgImgView?.addSubview(self.nameLabel!)
        self.nameLabel?.snp.makeConstraints{(make) in
            make.width.equalTo(150)
            make.height.equalTo(20)
            make.left.equalToSuperview().offset(17)
          make.top.equalToSuperview().offset(17)
        }
        
        self.typeBtn =  UIButton(type: UIButton.ButtonType.custom)
        self.typeBtn?.backgroundColor = UIColor.clear
        self.typeBtn?.setBackgroundImage(imageNamed("icon_withdraw_bank_type"), for:UIControl.State.normal)
        self.typeBtn?.isHighlighted = false
        self.typeBtn?.titleLabel?.font = UIFont.systemFont(ofSize: 10)
        self.typeBtn?.setTitle("储蓄卡", for: .normal)
        self.typeBtn?.setTitleColor(UIColor.white, for: .normal)
        self.typeBtn?.adjustsImageWhenHighlighted = false
        self.typeBtn?.isHidden = true
        self.bgImgView?.addSubview(self.typeBtn!)
        self.typeBtn?.snp.makeConstraints{(make) in
            make.width.equalTo(42)
            make.height.equalTo(14)
            make.left.equalTo((self.nameLabel?.snp.right)!).offset(6)
            make.top.equalToSuperview().offset(17)
        };
        
        
        self.noLabel = UILabel.init()
  //      self.noLabel?.text = "**** **** **** 3135"
        self.noLabel?.textColor = UIColor.white
        self.noLabel?.textAlignment = .left
        self.noLabel?.font = UIFont.systemFont(ofSize: 14)
        self.bgImgView?.addSubview(self.noLabel!)
        self.noLabel?.snp.makeConstraints{(make) in
            make.height.equalTo(20)
            make.top.equalTo((self.nameLabel?.snp.bottom)!).offset(10)
            make.left.equalToSuperview().offset(17)
        }
    }
    
    func setdata(dict:[String:Any]?) -> Void {
        self.nameLabel?.text = dict!["bankname"] as? String ?? ""
   //      self.iconImgView?.sd_setImage(with: URL.init(string: dict!["image_dep"] as? String ?? ""), completed: nil)
        let number = dict!["cardnum"] as? String ?? ""
        if number.count == 0{
            self.noLabel?.text = ""
        }else if number.count <= 4{
            self.noLabel?.text = "**** **** **** " + number
        }else{
            self.noLabel?.text = "**** **** **** " + number.suffix(4)
        }
    }
}
